package com.hilon.segment.mybatis.controller;

import com.hilon.segment.mybatis.pojo.po.system.SysMenuDo;
import com.hilon.segment.mybatis.service.AuthService;
import com.hilon.segment.mybatis.service.AuthenticationFacadeService;
import com.hilon.segment.mybatis.utils.ResultBean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AuthController {

    private final AuthService authService;
    private final AuthenticationFacadeService authenticationFacadeService;

    public AuthController(AuthenticationFacadeService authenticationFacadeService, AuthService authService) {
        this.authenticationFacadeService = authenticationFacadeService;
        this.authService = authService;
    }

    @GetMapping("/user-menus")
    public ResultBean<List<SysMenuDo>> listMenuByCurrentUser() {
        String currentUser = authenticationFacadeService.getAuthentication().getName();
        return authService.listMenuByCurrentUser(currentUser);
    }
}
